# -*- coding:utf-8 -*-
import os,sys
import re
import traceback
import time
from datetime import datetime
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), os.pardir))
import supeanut_config
from CommonLib.mylog import mylog
from SendOnline.SinaDaySend import SinaDaySend
from CommonLib.StockTool import StockTool


'''
作者：supeanut
创建时间：2016-xx-xx xx:xx:xx
功能描述：
	xxx
	xxxxx
相关配置：
	supeanut_config.XXX
历史改动：
	2016-xx-xx: xxxxxx
'''
class SinaDay2Mongo:
	# init what
	def __init__(self):
		self.obj = SinaDaySend()

	def process(self):
		log = mylog('Crontab.SinaDay2Mongo' ,None)
		today = datetime.today()
		date = today.strftime('%Y-%m-%d')
		# 判断交易日
		stocktool_obj = StockTool()
		flag, all_trade_date = stocktool_obj.get_trade_date()
		if flag is False:
			return False, 'get trade date faild'
		if date not in all_trade_date:
			return True, 'not trade date'
		flag, msg = self.obj.upsert_date([date])
		if flag is False:
			log.error(msg)




if __name__ == '__main__':
	obj = SinaDay2Mongo()
	print obj.process()
